<?php

/**
 * 删除餐厅tag
 * 
 * @copyright zhangchao
 * @since 2012-04-22
 */

include_once($_SERVER["DOCUMENT_ROOT"] . "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/include/foodv2/inc.php");

$g_cgival = array();
$g_pro = array();
$g_show = array();


function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;
	
	//check refer  -  add by xinwei
	if(! security_check::check_refer())
	{
		throw new Exception("来路不明");
	}
	
	cgi::both($g_cgival["tag_ids"], "tag_ids", "");
	$g_cgival["tag_ids"] = string::un_script_code($g_cgival["tag_ids"]);
	$g_cgival["tag_ids"] = string::un_html($g_cgival["tag_ids"]);
	if($g_cgival["tag_ids"] == "")
	{
		throw new Exception("tag_ids不能为空");
	}
}

function get_data()
{
	global $g_cgival, $g_pro, $g_show,$config;
	
	$admin_log = new admin_log();
	$site_id = admin::admin_get_user_site_id();
	$admin_id = admin::admin_get_login_uid();	// 拿到当前管理员ID
	$admin_name = admin::admin_get_login_user_name();	// 拿到当前管理员用户名
	$ids = explode(',', $g_cgival["tag_ids"]);
	$db_web_rstrt_tag = new db_web_rstrt_tag();
	$bool = $db_web_rstrt_tag->admin_delete_tag_by_ids($ids);
	if(!$bool)
	{
		throw new Exception("删除失败");
	}
	
	$admin_log->admin_insert_log_info($admin_id, $site_id, 18, "删除 标签餐厅id={$g_cgival["rstrt_id"]}");
}

try
{
	admin_check_login();
// 	admin_check_user_priv("foodv2/album_cover_template_add_post.php");
	
	check_cgi_pro();
	get_data();
	$g_show["error"] = 0;
	$g_show["errmsg"] = '';
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;


function show_pro()
{
	global $g_cgival, $g_pro, $g_show;
	if(isset($_GET['debug']))
		print_r($g_show);
	echo output::json('json',$g_show);
}

?>